import React from 'react';
import {View, Text} from 'react-native';

class ClassView extends React.Component {
  constructor(props) {
    super(props);
    const {name, age, level, sex} = props;
    this.state = {
      address: '广东省深圳市',
    };
  }
  componentDidMount() {
    console.log('componentDidMount ...');
    setTimeout(() => {
      this.setState({
        address: '浙江省杭州市',
      });
    }, 2000);
  }
  componentWillUnmount() {
    console.log('componentWillUnmount ...');
  }
  render() {
    const {name, age, level, sex} = this.props;
    const {address} = this.state;

    return (
      <View style={{width: 200, height: 200, backgroundColor: 'blue'}}>
        <Text>{`name=${name}，age=${age}，level=${level}，sex=${sex}`}</Text>
        <Text>{address}</Text>
      </View>
    );
  }
}

export default ClassView;
